//package com.itheima.tliassystem.aspect;
//
//import com.itheima.tliassystem.mapper.FileUpLoadMapper;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.time.LocalDateTime;
//
///**
// * @Auther: 爱编程的橙
// * @Date:2024/1/23
// * @Description:
// * @Version:1.11
// */
//@Aspect
//@Component
//public class FileUpAspect {
//
//    @Autowired
//    FileUpLoadMapper fileUpLoadMapper;
//    @Around("execution(com.itheima.tliassystem.controller.FileUploadController)")
//    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
//        Object[] args = joinPoint.getArgs();
//        MultipartFile file = (MultipartFile) args[0];
//        String originalFilename = file.getOriginalFilename();
//
//        Result result = (Result) joinPoint.proceed();
//        FileUploadLog fileUploadLog =
//                FileUploadLog.builder()
//                        .filename(originalFilename)
//                        .extname(originalFilename.substring(originalFilename.lastIndexOf(".")))
//                        .url(result.getData().toString())
//                        .size(file.getSize())
//                        .uploadTime(LocalDateTime.now())
//                .build();
//        fileUpLoadMapper.insertFileUploadLog(fileUploadLog);
//
//        return result;
//
//    }
//}
